// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using System;
using System.Linq;
using Elastic.Clients.Elasticsearch.Serialization;

namespace Elastic.Clients.Elasticsearch.IndexManagement;

public sealed partial class PutSampleConfigurationRequestParameters : Elastic.Transport.RequestParameters
{
	/// <summary>
	/// <para>
	/// Period to wait for a connection to the master node. If no response is
	/// received before the timeout expires, the request fails and returns an
	/// error.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("master_timeout"); set => Q("master_timeout", value); }

	/// <summary>
	/// <para>
	/// Period to wait for a response.
	/// If no response is received before the timeout expires, the request fails and returns an error.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("timeout"); set => Q("timeout", value); }
}

/// <summary>
/// <para>
/// Create or update sampling configuration.
/// </para>
/// <para>
/// Create or update the sampling configuration for the specified index.
/// </para>
/// </summary>
[System.Text.Json.Serialization.JsonConverter(typeof(Elastic.Clients.Elasticsearch.IndexManagement.Json.PutSampleConfigurationRequestConverter))]
public sealed partial class PutSampleConfigurationRequest : Elastic.Clients.Elasticsearch.Requests.PlainRequest<Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestParameters>
{
	[System.Obsolete("The request contains additional required properties that must be initialized. Please use an alternative constructor to ensure all required values are properly set.")]
	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public PutSampleConfigurationRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r.Required("index", index))
	{
	}

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public PutSampleConfigurationRequest(Elastic.Clients.Elasticsearch.IndexName index, double rate) : base(r => r.Required("index", index))
	{
		Rate = rate;
	}
#if NET7_0_OR_GREATER
	public PutSampleConfigurationRequest()
	{
	}
#endif
	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	internal PutSampleConfigurationRequest(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel sentinel)
	{
		_ = sentinel;
	}

	internal override Elastic.Clients.Elasticsearch.Requests.ApiUrls ApiUrls => Elastic.Clients.Elasticsearch.Requests.ApiUrlLookup.IndexManagementPutSampleConfiguration;

	protected override Elastic.Transport.HttpMethod StaticHttpMethod => Elastic.Transport.HttpMethod.PUT;

	internal override bool SupportsBody => true;

	internal override string OperationName => "indices.put_sample_configuration";

	/// <summary>
	/// <para>
	/// The name of the index or data stream.
	/// </para>
	/// </summary>
	public
#if NET7_0_OR_GREATER
	required
#endif
	Elastic.Clients.Elasticsearch.IndexName Index { get => P<Elastic.Clients.Elasticsearch.IndexName>("index"); set => PR("index", value); }

	/// <summary>
	/// <para>
	/// Period to wait for a connection to the master node. If no response is
	/// received before the timeout expires, the request fails and returns an
	/// error.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("master_timeout"); set => Q("master_timeout", value); }

	/// <summary>
	/// <para>
	/// Period to wait for a response.
	/// If no response is received before the timeout expires, the request fails and returns an error.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("timeout"); set => Q("timeout", value); }

	/// <summary>
	/// <para>
	/// An optional condition script that sampled documents must satisfy.
	/// </para>
	/// </summary>
	public string? If { get; set; }

	/// <summary>
	/// <para>
	/// The maximum number of documents to sample. Must be greater than 0 and less than or equal to 10,000.
	/// </para>
	/// </summary>
	public int? MaxSamples { get; set; }

	/// <summary>
	/// <para>
	/// The maximum total size of sampled documents. Must be greater than 0 and less than or equal to 5GB.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.ByteSize? MaxSize { get; set; }

	/// <summary>
	/// <para>
	/// The fraction of documents to sample. Must be greater than 0 and less than or equal to 1.
	/// Can be specified as a number or a string.
	/// </para>
	/// </summary>
	public
#if NET7_0_OR_GREATER
	required
#endif
	double Rate { get; set; }

	/// <summary>
	/// <para>
	/// The duration for which the sampled documents should be retained.
	/// Must be greater than 0 and less than or equal to 30 days.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Duration? TimeToLive { get; set; }
}

/// <summary>
/// <para>
/// Create or update sampling configuration.
/// </para>
/// <para>
/// Create or update the sampling configuration for the specified index.
/// </para>
/// </summary>
public readonly partial struct PutSampleConfigurationRequestDescriptor
{
	internal Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequest Instance { get; init; }

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public PutSampleConfigurationRequestDescriptor(Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequest instance)
	{
		Instance = instance;
	}

	public PutSampleConfigurationRequestDescriptor(Elastic.Clients.Elasticsearch.IndexName index)
	{
#pragma warning disable CS0618
		Instance = new Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequest(index);
#pragma warning restore CS0618
	}

	[System.Obsolete("The use of the parameterless constructor is not permitted for this type.")]
	public PutSampleConfigurationRequestDescriptor()
	{
		throw new System.InvalidOperationException("The use of the parameterless constructor is not permitted for this type.");
	}

	public static explicit operator Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor(Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequest instance) => new Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor(instance);
	public static implicit operator Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequest(Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor descriptor) => descriptor.Instance;

	/// <summary>
	/// <para>
	/// The name of the index or data stream.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor Index(Elastic.Clients.Elasticsearch.IndexName value)
	{
		Instance.Index = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// Period to wait for a connection to the master node. If no response is
	/// received before the timeout expires, the request fails and returns an
	/// error.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor MasterTimeout(Elastic.Clients.Elasticsearch.Duration? value)
	{
		Instance.MasterTimeout = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// Period to wait for a response.
	/// If no response is received before the timeout expires, the request fails and returns an error.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor Timeout(Elastic.Clients.Elasticsearch.Duration? value)
	{
		Instance.Timeout = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// An optional condition script that sampled documents must satisfy.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor If(string? value)
	{
		Instance.If = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// The maximum number of documents to sample. Must be greater than 0 and less than or equal to 10,000.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor MaxSamples(int? value)
	{
		Instance.MaxSamples = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// The maximum total size of sampled documents. Must be greater than 0 and less than or equal to 5GB.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor MaxSize(Elastic.Clients.Elasticsearch.ByteSize? value)
	{
		Instance.MaxSize = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// The maximum total size of sampled documents. Must be greater than 0 and less than or equal to 5GB.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor MaxSize(System.Func<Elastic.Clients.Elasticsearch.ByteSizeFactory, Elastic.Clients.Elasticsearch.ByteSize> action)
	{
		Instance.MaxSize = Elastic.Clients.Elasticsearch.ByteSizeFactory.Build(action);
		return this;
	}

	/// <summary>
	/// <para>
	/// The fraction of documents to sample. Must be greater than 0 and less than or equal to 1.
	/// Can be specified as a number or a string.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor Rate(double value)
	{
		Instance.Rate = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// The duration for which the sampled documents should be retained.
	/// Must be greater than 0 and less than or equal to 30 days.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor TimeToLive(Elastic.Clients.Elasticsearch.Duration? value)
	{
		Instance.TimeToLive = value;
		return this;
	}

	[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
	internal static Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequest Build(System.Action<Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor> action)
	{
		var builder = new Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor(new Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequest(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance));
		action.Invoke(builder);
		return builder.Instance;
	}

	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor ErrorTrace(bool? value)
	{
		Instance.ErrorTrace = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor FilterPath(params string[]? value)
	{
		Instance.FilterPath = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor Human(bool? value)
	{
		Instance.Human = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor Pretty(bool? value)
	{
		Instance.Pretty = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor SourceQueryString(string? value)
	{
		Instance.SourceQueryString = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor RequestConfiguration(Elastic.Transport.IRequestConfiguration? value)
	{
		Instance.RequestConfiguration = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor RequestConfiguration(System.Func<Elastic.Transport.RequestConfigurationDescriptor, Elastic.Transport.IRequestConfiguration>? configurationSelector)
	{
		Instance.RequestConfiguration = configurationSelector.Invoke(Instance.RequestConfiguration is null ? new Elastic.Transport.RequestConfigurationDescriptor() : new Elastic.Transport.RequestConfigurationDescriptor(Instance.RequestConfiguration)) ?? Instance.RequestConfiguration;
		return this;
	}
}

/// <summary>
/// <para>
/// Create or update sampling configuration.
/// </para>
/// <para>
/// Create or update the sampling configuration for the specified index.
/// </para>
/// </summary>
public readonly partial struct PutSampleConfigurationRequestDescriptor<TDocument>
{
	internal Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequest Instance { get; init; }

	[System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
	public PutSampleConfigurationRequestDescriptor(Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequest instance)
	{
		Instance = instance;
	}

	public PutSampleConfigurationRequestDescriptor(Elastic.Clients.Elasticsearch.IndexName index)
	{
#pragma warning disable CS0618
		Instance = new Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequest(index);
#pragma warning restore CS0618
	}

	public PutSampleConfigurationRequestDescriptor()
	{
#pragma warning disable CS0618
		Instance = new Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequest(typeof(TDocument));
#pragma warning restore CS0618
	}

	public static explicit operator Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor<TDocument>(Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequest instance) => new Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor<TDocument>(instance);
	public static implicit operator Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequest(Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor<TDocument> descriptor) => descriptor.Instance;

	/// <summary>
	/// <para>
	/// The name of the index or data stream.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor<TDocument> Index(Elastic.Clients.Elasticsearch.IndexName value)
	{
		Instance.Index = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// Period to wait for a connection to the master node. If no response is
	/// received before the timeout expires, the request fails and returns an
	/// error.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor<TDocument> MasterTimeout(Elastic.Clients.Elasticsearch.Duration? value)
	{
		Instance.MasterTimeout = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// Period to wait for a response.
	/// If no response is received before the timeout expires, the request fails and returns an error.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor<TDocument> Timeout(Elastic.Clients.Elasticsearch.Duration? value)
	{
		Instance.Timeout = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// An optional condition script that sampled documents must satisfy.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor<TDocument> If(string? value)
	{
		Instance.If = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// The maximum number of documents to sample. Must be greater than 0 and less than or equal to 10,000.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor<TDocument> MaxSamples(int? value)
	{
		Instance.MaxSamples = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// The maximum total size of sampled documents. Must be greater than 0 and less than or equal to 5GB.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor<TDocument> MaxSize(Elastic.Clients.Elasticsearch.ByteSize? value)
	{
		Instance.MaxSize = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// The maximum total size of sampled documents. Must be greater than 0 and less than or equal to 5GB.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor<TDocument> MaxSize(System.Func<Elastic.Clients.Elasticsearch.ByteSizeFactory, Elastic.Clients.Elasticsearch.ByteSize> action)
	{
		Instance.MaxSize = Elastic.Clients.Elasticsearch.ByteSizeFactory.Build(action);
		return this;
	}

	/// <summary>
	/// <para>
	/// The fraction of documents to sample. Must be greater than 0 and less than or equal to 1.
	/// Can be specified as a number or a string.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor<TDocument> Rate(double value)
	{
		Instance.Rate = value;
		return this;
	}

	/// <summary>
	/// <para>
	/// The duration for which the sampled documents should be retained.
	/// Must be greater than 0 and less than or equal to 30 days.
	/// </para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor<TDocument> TimeToLive(Elastic.Clients.Elasticsearch.Duration? value)
	{
		Instance.TimeToLive = value;
		return this;
	}

	[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
	internal static Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequest Build(System.Action<Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor<TDocument>> action)
	{
		var builder = new Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor<TDocument>(new Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequest(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance));
		action.Invoke(builder);
		return builder.Instance;
	}

	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor<TDocument> ErrorTrace(bool? value)
	{
		Instance.ErrorTrace = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor<TDocument> FilterPath(params string[]? value)
	{
		Instance.FilterPath = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor<TDocument> Human(bool? value)
	{
		Instance.Human = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor<TDocument> Pretty(bool? value)
	{
		Instance.Pretty = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor<TDocument> SourceQueryString(string? value)
	{
		Instance.SourceQueryString = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor<TDocument> RequestConfiguration(Elastic.Transport.IRequestConfiguration? value)
	{
		Instance.RequestConfiguration = value;
		return this;
	}

	public Elastic.Clients.Elasticsearch.IndexManagement.PutSampleConfigurationRequestDescriptor<TDocument> RequestConfiguration(System.Func<Elastic.Transport.RequestConfigurationDescriptor, Elastic.Transport.IRequestConfiguration>? configurationSelector)
	{
		Instance.RequestConfiguration = configurationSelector.Invoke(Instance.RequestConfiguration is null ? new Elastic.Transport.RequestConfigurationDescriptor() : new Elastic.Transport.RequestConfigurationDescriptor(Instance.RequestConfiguration)) ?? Instance.RequestConfiguration;
		return this;
	}
}